/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.subway.persistencias;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "persona", catalog = "bd_subway", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Persona.findAll", query = "SELECT p FROM Persona p"),
    @NamedQuery(name = "Persona.findByPersonaId", query = "SELECT p FROM Persona p WHERE p.personaId = :personaId"),
    @NamedQuery(name = "Persona.findByPersonaNombre", query = "SELECT p FROM Persona p WHERE p.personaNombre = :personaNombre"),
    @NamedQuery(name = "Persona.findByPersonaApellido", query = "SELECT p FROM Persona p WHERE p.personaApellido = :personaApellido"),
    @NamedQuery(name = "Persona.findByPersonaFechaNac", query = "SELECT p FROM Persona p WHERE p.personaFechaNac = :personaFechaNac")})
public class Persona implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "personaId")
    private Integer personaId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "personaNombre", nullable = false, length = 30)
    private String personaNombre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "personaApellido", nullable = false, length = 30)
    private String personaApellido;
    @Basic(optional = false)
    @NotNull
    @Column(name = "personaFechaNac", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date personaFechaNac;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "empPersonaId")
    private List<Empleado> empleadoList;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "docPropietarioId")
    private CatDocumento catDocumento;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "telPropietarioId")
    private List<CatTelefono> catTelefonoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "clientePersonaId")
    private List<Cliente> clienteList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usuarioPersonaId")
    private List<UsuarioPersonaRol> usuarioPersonaRolList;
    @JoinColumn(name = "personaDireccionId", referencedColumnName = "dirId", nullable = false)
    @ManyToOne(optional = false)
    private CatDireccion personaDireccionId;

    public Persona() {
    }

    public Persona(Integer personaId) {
        this.personaId = personaId;
    }

    public Persona(Integer personaId, String personaNombre, String personaApellido, Date personaFechaNac) {
        this.personaId = personaId;
        this.personaNombre = personaNombre;
        this.personaApellido = personaApellido;
        this.personaFechaNac = personaFechaNac;
    }

    public Integer getPersonaId() {
        return personaId;
    }

    public void setPersonaId(Integer personaId) {
        this.personaId = personaId;
    }

    public String getPersonaNombre() {
        return personaNombre;
    }

    public void setPersonaNombre(String personaNombre) {
        this.personaNombre = personaNombre;
    }

    public String getPersonaApellido() {
        return personaApellido;
    }

    public void setPersonaApellido(String personaApellido) {
        this.personaApellido = personaApellido;
    }

    public Date getPersonaFechaNac() {
        return personaFechaNac;
    }

    public void setPersonaFechaNac(Date personaFechaNac) {
        this.personaFechaNac = personaFechaNac;
    }

    @XmlTransient
    public List<Empleado> getEmpleadoList() {
        return empleadoList;
    }

    public void setEmpleadoList(List<Empleado> empleadoList) {
        this.empleadoList = empleadoList;
    }

    public CatDocumento getCatDocumento() {
        return catDocumento;
    }

    public void setCatDocumento(CatDocumento catDocumento) {
        this.catDocumento = catDocumento;
    }

    @XmlTransient
    public List<CatTelefono> getCatTelefonoList() {
        return catTelefonoList;
    }

    public void setCatTelefonoList(List<CatTelefono> catTelefonoList) {
        this.catTelefonoList = catTelefonoList;
    }

    @XmlTransient
    public List<Cliente> getClienteList() {
        return clienteList;
    }

    public void setClienteList(List<Cliente> clienteList) {
        this.clienteList = clienteList;
    }

    @XmlTransient
    public List<UsuarioPersonaRol> getUsuarioPersonaRolList() {
        return usuarioPersonaRolList;
    }

    public void setUsuarioPersonaRolList(List<UsuarioPersonaRol> usuarioPersonaRolList) {
        this.usuarioPersonaRolList = usuarioPersonaRolList;
    }

    public CatDireccion getPersonaDireccionId() {
        return personaDireccionId;
    }

    public void setPersonaDireccionId(CatDireccion personaDireccionId) {
        this.personaDireccionId = personaDireccionId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (personaId != null ? personaId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Persona)) {
            return false;
        }
        Persona other = (Persona) object;
        if ((this.personaId == null && other.personaId != null) || (this.personaId != null && !this.personaId.equals(other.personaId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return personaApellido + ", " + personaNombre;
    }
    
}
